from django.contrib import admin
from django.urls import path, include
from .views import StudentViewSet, ClassesViewSet
from rest_framework.routers import DefaultRouter

urlpatterns = [
    # 127.0.0.1:8000/drfstudy/students/
    # get id retrieve
    # 不带 id
    # path('students/', StudentViewSet.as_view({'get': 'list', 'post': 'create'})),
    # # 带 id
    # path('students/<pk>/', StudentViewSet.as_view({'get': 'retrieve', 'put': 'update', 'delete': 'destroy'}))
]
# 实例化 创建路由器对象
router = DefaultRouter()
# 127.0.0.1:8000/drfstudy/students/
router.register('students', StudentViewSet)  # 注册请求路由
# 127.0.0.1:8000/drfstudy/classes/
router.register('classes', ClassesViewSet)
urlpatterns += router.urls  # 拼接路由
